/*
 * @Author: your name
 * @Date: 2022-03-28 15:00:43
 * @LastEditTime: 2022-05-03 08:44:14
 * @LastEditors: your name
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 * @FilePath: \VScodeToWeb\bookWebApi\routes\books.js
 */
const express = require('express')
const router = express.Router()
const common = require('../util/common.js')
const fetch = require('../controller/fetch.js')
const book = require('../controller/book')

// router.all('*', common.checkLogin);

//获取全部书籍信息
router.get('/', book.findAll)

//指定关键字搜索
router.get('/search', book.search)

//搜索指定关键字
router.get('/isbn/:isbn', book.findByIsbn)

//从网页信息源获取指定ISBN书籍信息
//http://localhost:3001/books/fetch/9787521738575本地访问地址 
 //locahost:3001/books/fetch/isbn就是当前自己选择书籍的isbn编号
router.get('/fetch/:isbn', fetch.fetch)

//获取指定书籍信息
router.get('/:id', book.find)

//新增书籍信息
router.post('/', book.add)

//修改书籍信息
router.put('/:id', book.update)

//删除书籍信息
router.delete('/:id', book.remove)

module.exports = router
